package com.yangrui.app.config;

import com.yangrui.app.interceptor.CorsInterceptor;
import com.yangrui.app.interceptor.TokenInterceptor;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Component
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(new CorsInterceptor()).addPathPatterns("/**");


        registry.addInterceptor(new TokenInterceptor()).
                addPathPatterns("/api/v1/**").
                excludePathPatterns("/api/v1/login","/api/v1/register");
    }
}
